package J.算法.动态规划;

public class _509斐波那契数 {

    /**
     * 迭代
     * @param n
     * @return
     */
    public int fib(int n) {
        if (n<2){
            return n;
        }

        int prev = 0,cur = 1;
        for (int i = 2; i <= n; i++) {
            int temp = prev+cur;
            prev = cur;
            cur = temp;

        }
        return cur;


    }

}
